//
//  ClassifyCell.m
//  SuperRadio
//
//  Created by Damon on 14/12/18.
//  Copyright (c) 2014年 三个臭皮匠. All rights reserved.
//

#import "ClassifyCell.h"
#import "ClassifyOfList.h"
#import "UIImageView+WebCache.h"

@interface ClassifyCell ()

// 定义cell的图片和标题的属性
@property(nonatomic, retain) UIImageView *classifyImage;
@property(nonatomic, retain) UILabel *classifyTitle;

@end


@implementation ClassifyCell

// 初始化 设置创建的属性
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.classifyImage = [[UIImageView alloc] init];
        
        [self.contentView addSubview:self.classifyImage];
        [_classifyImage release];
        
        self.classifyTitle =[[UILabel alloc] init];
        self.classifyTitle.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:self.classifyTitle];
        [_classifyTitle release];
        
    }
    return self;
    
}


// 重写setter方法 给属性赋值
- (void)setClassifyOfList:(ClassifyOfList *)classifyOfList
{
    if (_classifyOfList != classifyOfList) {
        [_classifyOfList release];
        _classifyOfList = [classifyOfList retain];
    }
    
    [self.classifyImage setImageWithURL:[NSURL URLWithString:[_classifyOfList.cover_path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
    self.classifyTitle.text = _classifyOfList.tname;
    self.classifyTitle.font = [UIFont systemFontOfSize:14];
}


// 设置cell位置 的方法
- (void)layoutSubviews
{
    [super layoutSubviews];
    
    
    self.classifyImage.frame = CGRectMake(10, 10, self.contentView.frame.size.width - 20, self.contentView.frame.size.height / 2 + 20);
    
    self.classifyTitle.frame = CGRectMake(10, self.contentView.frame.size.height / 2 + 30, self.contentView.frame.size.width - 20, self.contentView.frame.size.height / 2 - 30);
    
    
    
}


- (void)dealloc
{
    [_classifyOfList release];
    
    [_classifyImage release];
    [_classifyTitle release];
    
    [super dealloc];
}


@end
